{{ define "graph" }}
  <h3>{{ .arg0 }}</h3>
  <div id="{{ .arg1 }}">
  <script>
    new PromConsole.Graph({
    node: document.querySelector("#{{ .arg1 }}"),
    expr: {{ .arg2 }},
    height: 100,
    yTitle: {{ .arg3 }},
  })
  </script>
  </div>
{{ end }}

{{ template "head" . }}

{{ template "prom_content_head" . }}
  <h1>Validators Top Level System {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</h1>

  <h3>Submit Txn Rate (AC)</h3>
  <div id="acTxnRate">
  <script>
    new PromConsole.Graph({
    node: document.querySelector("#acTxnRate"),
    expr: "avg(irate(num_req{method='admission_control.AdmissionControl.SubmitTransaction'}[1m])) by (peer_id)",
    renderer: "area",
    height: 100,
    yTitle: "Txn/s",
  })
  </script>
  </div>

  <h3>CPU Usage</h3>
  <div id="cpuGraph">
  <script>
  new PromConsole.Graph({
  node: document.querySelector("#cpuGraph"),
  height: 100,
  expr: "100 * (1 - avg by(address)(rate(node_cpu_seconds_total{job='validator_instances',mode='idle'}[5m])))",
    max: 100,
    yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
    yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
    yTitle: 'CPU %',
  })
  </script>
  </div>

  {{ template "graph" (args "Txn per Block " "ccTxnBlock" "avg(rate(consensus{op='committed_txns_count'}[1m]))/avg(rate(consensus{op='committed_blocks_count'}[1m]))" "Txn per Block") }}

  {{ template "graph" (args "Finality (MP)" "mpFinality" "avg(rate(mempool_duration_sum{op='e2e.latency'}[1m])/rate(mempool_duration_count{op='e2e.latency'}[1m]))" "ms(avg)") }}

  {{ template "graph" (args "Round" "ccRound" "avg(consensus_gauge{op='current_round'}) by (peer_id)" "Round") }}

{{ template "prom_content_tail" . }}

{{ template "tail" }}
